package com.tanqing.ddd.web.service.impl;

import com.tanqing.ddd.domain.entity.Plate;
import com.tanqing.ddd.domain.service.AlarmService;
import com.tanqing.ddd.web.convert.AlarmConvert;
import com.tanqing.ddd.web.entity.Alarm;
import com.tanqing.ddd.web.mapper.AlarmMapper;
import com.tanqing.ddd.web.service.IAlarmService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tanqing.ddd.web.vo.AlarmVo;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zs
 * @since 2024-01-15
 */
@Service
public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements IAlarmService, AlarmService {

    @Override
    public void alerm(Plate plate, String message) {
        AlarmVo alarmVo = new AlarmVo();
        alarmVo.setPlate(plate.getPlateNumber());
        alarmVo.setMsg(message);
        alarmVo.setTime(new Date());
        Alarm alarm = AlarmConvert.INSTANCE.convert(alarmVo);
        this.save(alarm);

    }
}
